const { WebSocketServer } = require("ws");
const wss = new WebSocketServer({  port: 9999 }); // ws server
console.log("\n## => uni-pptx ws server start...\n");

wss.on("connection", (conn, req) => {
  console.log("用户连接 ws server.\n");
  // 监听消息
  conn.onmessage = (event) => {
    wss.clients.forEach((c) => {
      c.send(event.data);
    });
  };

  conn.onclose = () => {
    console.warn("用户关闭连接\n");
  };
});
